package com.beiding.jsonanalyzer.querylink;

import com.beiding.jsonanalyzer.flow.BranchNode;
import com.beiding.jsonanalyzer.flow.ValueNode;
import com.beiding.jsonanalyzer.visit.VisitAble;

/**
 * 背压
 *
 * @param <W>
 */
public class BreakPressureQueryLinkNode<W extends ValueNode> extends QueryLinkNodeAdapter<W> {

    private int maxSize;

    public BreakPressureQueryLinkNode(QueryLinkNode<W> pre, int maxSize) {
        super(pre);
        this.maxSize = maxSize;
    }

    @Override
    protected VisitAble<BranchNode<W>> doExec(VisitAble<BranchNode<W>> preResult) {
        return visitor -> {
            preResult.visit(node -> {

                node.breakPressure(maxSize);

                //不做任何处理
                visitor.onNode(node);

            });
        };
    }
}
